package com.huawei.appmarket.service.externalapi.actions;

import android.content.Intent;
import android.text.TextUtils;
import com.huawei.appmarket.service.appmgr.view.activity.AppManagerProtocol;
import com.huawei.appmarket.service.deamon.download.remote.DownloadAgentService;
import com.huawei.secure.android.common.intent.SafeIntent;
import o.Logger;
import o.ContentManager;
import o.dyr;
import o.dys.a;

public class LauncherManagerApp extends dyr {
    private static final String TAG = "LauncherManagerApp";

    public LauncherManagerApp(a aVar) {
        super(aVar);
    }

    public void onAction() {
        SafeIntent safeIntent = new SafeIntent(this.callback.getIntent());
        String stringExtra = safeIntent.getStringExtra(DownloadAgentService.PACKAGE_NMAE_ARG);
        int intExtra = safeIntent.getIntExtra(DownloadAgentService.COMMAND_ARG, -1);
        if (TextUtils.isEmpty(stringExtra)) {
            Logger.e(TAG, "packageName error:" + stringExtra);
            DownloadAgentService.setResult(ContentManager.getInstant().getContext(), -1, new Intent());
        } else {
            DownloadAgentService.doCommand(stringExtra, intExtra);
            AppManagerProtocol appManagerProtocol = new AppManagerProtocol();
            appManagerProtocol.ˊ().ॱ(false);
            this.callback.ˎ(appManagerProtocol.ˎ(), 0);
        }
        this.callback.finish();
    }

    public void cancelTask() {
        SafeIntent safeIntent = new SafeIntent(this.callback.getIntent());
        if (this.callback.getIntent() != null) {
            DownloadAgentService.sendPauseMessage(safeIntent.getStringExtra(DownloadAgentService.PACKAGE_NMAE_ARG));
        }
    }

    public void onPause() {
        SafeIntent safeIntent = new SafeIntent(this.callback.getIntent());
        if (this.callback.getIntent() != null) {
            DownloadAgentService.sendPauseMessage(safeIntent.getStringExtra(DownloadAgentService.PACKAGE_NMAE_ARG));
        }
    }
}
